<template>
  <div>
    <h2>student姓名：{{name}}</h2>
    <h2>student年龄：{{age}}</h2>
    <h2>student性别：{{gender}}</h2>
    <button @click="showInof()">显示student信息</button>
    <button @click="selectAll()">获得所有学生信息</button>
  </div>
</template>
  
<script>
  import axios from 'axios'

  export default {
    name: 'Student',
    props: ['name', 'age'],
    data() {
      return {
         gender: '男'  
      }
    },
    methods: {
      showInof() {
        alert(this.name + " : " + this.age);
      },
      selectAll() {
        axios.get('/api/student/selectAll').then(response => {
          console.log(response)
          console.log(response.data)
        })
      }
    },
    mounted() {
      //this.$bus.$on监听事件
      this.$bus.$on('updateBanjiName', (data) => {
        console.log('我是Student组件，我收到了Banji组件发送过来的班级的名字：' + data)
      })
    },
  }
</script>
 
<style scoped>
   
</style>